package com.tanhua.manage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.manage.pojo.Role;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface RoleMapper extends BaseMapper<Role> {

    List<Role> findAll();

    int deleteRoleById(@Param("id") Long id);

    int deleteRoleAndPermissionByRoleId(@Param("id") Long id);

    int saveRoleIdAndPermissionId(@Param("roleId") Long roleId, @Param("permissionId") Integer permissionId);

    @Select("select role_name from tb_admin_role where id =(select role_id from tb_admin_user where user_name = #{username} )")
    public String findRole(@Param("username") String username);
}
